#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int sum=0;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        int x=lower_bound(a+1,a+n+1,a[i]+1)-a;
        cout<<x<<" ";
        if(x<=n&&x>i&&a[x]>a[i]&&a[i]!=-1){
            cout<<a[x];
            a[x]=-1;
            sum++;
        }
        cout<<endl;
    }
    cout<<n-sum;
    return 0;
}
